package com.csdj.controller;



import com.csdj.service.IBlogService;
import com.csdj.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zq
 * @since 2024-12-11
 */
@RestController
@RequestMapping("/blog")
@CrossOrigin
public class BlogController {
    @Autowired
    private IBlogService blogService;

    @GetMapping("getallblog")
    public Object getallblog(){
        return blogService.list();
    }
    @GetMapping("page")
    public Result<?> page(@RequestParam(defaultValue = "1") Integer pageNum,
                       @RequestParam(defaultValue = "9") Integer pageSize) {

        return Result.success(blogService.getBlogsByPage(pageNum,pageSize));
    }
}
